﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq;

public partial class Pages_Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int id_cat = int.Parse(Request.QueryString["category"]);
        PresentsDataClassesDataContext dc = new PresentsDataClassesDataContext();
        var results = from c in dc.Presents
                      join d in dc.Catalog on c.id_present equals d.id_present
                      where d.id_category == id_cat
                      select c;
        ListView1.DataSource = results.ToArray();
        ListView1.DataBind();
    }

    // fires when an Add to Cart button is clicked
    protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // The CommandArgument of the clicked Button contains the ProductID
        string productId = e.CommandArgument.ToString();
        // Add the product to the shopping cart
        ShoppingCartAccess.AddItem(productId);
    }
}